import Vue from 'vue'
import Router from 'vue-router'
// 经济信息
import economicinfo from '@/components/economicinfo'
// 环境信息
import environmeninfo from '@/components/environmeninfo'
// 附近断裂带
import nearfz from '@/components/nearfz'
// 人口信息
import populationinfo from '@/components/populationinfo'
// 地震信息
import seismicinfo from '@/components/seismicinfo'
// 三维地形图
import thd from '@/components/thd'
// 天气信息
import weatherinfo from '@/components/weatherinfo'
//全球历史地震
import worldEq from '@/components/worldEq'
import computer from '@/components/computer'
import home from '@/components/home'
import error from '@/components/error'
import store from '@/store'
import title from '@/assets/title.json'
import dashboard from '@/components/dashboard'

Vue.use(Router)

const router = new Router({
  routes: [{
      name: 'home',
      path: '/home/:eqid',
      component: home,
      children: [{
          name: 'default',
          path: '',
          component: seismicinfo
        },
        {
          name: 'seismicinfo',
          path: 'seismicinfo',
          component: seismicinfo
        },
        {
          name: 'thd',
          path: 'thd',
          component: thd
        },
        {
          name: 'weatherinfo',
          path: 'weatherinfo',
          component: weatherinfo
        },
        {
          name: 'populationinfo',
          path: 'populationinfo',
          component: populationinfo
        },
        {
          name: 'economicinfo',
          path: 'economicinfo',
          component: economicinfo
        },
        {
          name: 'environmeninfo',
          path: 'environmeninfo',
          component: environmeninfo
        },
        {
          name: 'nearfz',
          path: 'nearfz',
          component: nearfz
        },
        {
          name: 'computer',
          component: computer,
          path: '/home/:eqid/computer',
          children: [{
              path: '',
              component: seismicinfo
            },
            {
              name: 'worldEq',
              path: 'worldEq',
              component: worldEq
            },
            {
              name: 'cthd',
              path: 'cthd',
              component: thd
            },
            {
              name: 'cseismicinfo',
              path: 'cseismicinfo',
              component: seismicinfo
            },
            {
              name: 'dashboard',
              path: 'dashboard',
              component: dashboard
            }
          ]
        }
      ]
    },
    {
      name: 'error',
      path: '*',
      component: error
    }
  ]
});
router.beforeEach((to, from, next) => {
  var name = title[to.name];
  store.commit('seteqhead', name);
  next();
});
export default router;
